﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using XMLSpreadGear.Core;

namespace XMLSpreadGear.Headers
{
    public class ExcelWorkbook:BaseElement
    {
        private int? iWindowHeight;

        public int? WindowHeight
        {
            get { return iWindowHeight; }
            set { iWindowHeight = value; }
        }
        private int? iWindowWidth;

        public int? WindowWidth
        {
            get { return iWindowWidth; }
            set { iWindowWidth = value; }
        }
        private int? iWindowTopX;

        public int? WindowTopX
        {
            get { return iWindowTopX; }
            set { iWindowTopX = value; }
        }
        private int? iWindowTopY;

        public int? WindowTopY
        {
            get { return iWindowTopY; }
            set { iWindowTopY = value; }
        }
        private bool bProtectStructure;

        public bool ProtectStructure
        {
            get { return bProtectStructure; }
            set { bProtectStructure = value; }
        }
        private bool bProtectWindow;

        public bool ProtectWindow
        {
            get { return bProtectWindow; }
            set { bProtectWindow = value; }
        }

        public ExcelWorkbook(string strname)
            : base(strname)
        {
        }
        public ExcelWorkbook(string strname, int windowheight, int windowwidth, int windowtopx, int windowtopy, bool protectstructure, bool protectwindow)
            : this(strname)
        {
            this.iWindowHeight = windowheight;
            this.iWindowTopX = windowtopx;
            this.iWindowTopY = windowtopy;
            this.iWindowWidth = windowwidth;
            this.bProtectStructure = protectstructure;
            this.bProtectWindow = protectwindow;
        }
        internal protected override IDictionary<string, string> RegisterElements()
        {
            IDictionary<string, string> dic = new Dictionary<string, string>();

            if (this.WindowHeight != null)
            {
                dic.Add("WindowHeight", AddGenericElement("WindowHeight",this.WindowHeight.ToString()));
            }
            if (this.WindowWidth != null)
            {
                dic.Add("WindowWidth", AddGenericElement("WindowWidth", this.WindowWidth.ToString()));
            }

            if (this.WindowTopX != null)
            {
                dic.Add("WindowTopX", AddGenericElement("WindowTopX", this.WindowTopX.ToString()));
            }
            if (this.WindowTopY != null)
            {
                dic.Add("WindowTopY", AddGenericElement("WindowTopY", this.WindowTopY.ToString()));
            }

            if (this.ProtectStructure != null)
            {
                dic.Add("ProtectStructure", AddGenericElement("ProtectStructure", this.ProtectStructure.ToString()));
            }

            if (this.ProtectWindow != null)
            {
                dic.Add("ProtectWindow", AddGenericElement("ProtectWindow", this.ProtectWindow.ToString()));
            }
            return dic;
        }

        internal protected override IDictionary<string, string> RegisterAttributes()
        {
            IDictionary<string, string> dic = new Dictionary<string, string>();
            dic.Add("xmlns", "urn:schemas-microsoft-com:office:excel");
            return dic;
        }

        protected override void SetDefaults()
        {
            return;
        }
    }
}
